package com.jrx.anytxn.customer.mapper.ext;

import com.jrx.anytxn.customer.entity.TlRightsExchangeLog;
import com.jrx.anytxn.customer.mapper.base.TlRightsExchangeLogMapper;

import java.util.List;

/**
 * ClassName ExtTlRightsExchangeLogMapper
 *
 * @author lujianyou
 * @version 1.0
 * @description 权益资格兑换流水表 mapper
 * @date 2021/6/25 10:41
 **/
public interface ExtTlRightsExchangeLogMapper extends TlRightsExchangeLogMapper {

    void updateByTenantAndId(TlRightsExchangeLog tlRightsExchangeLog);

    /**
     * 根据 客户号、租户号、渠道号 查询客户权益资格兑换流水列表
     * @param customerId
     * @param tenantId
     * @param channel
     * @return
     */
    List<TlRightsExchangeLog> selectByCustomerIdAndTenantIdAndChannel(String customerId, String tenantId, String channel);

    /**
     *
     * @param tenantId 租户号
     * @param orderState 下单订单状态：0-处理中 1-未处理 2-处理成功 3-失败
     * @param channel
     * @return
     */
    List<TlRightsExchangeLog> selectByTenantIdAndOrderStateAndChannel(String tenantId, String orderState, String channel);

    /**
     * 更新权益兑换明细表
     * @param tenantId 租户号
     * @param sceneOrderId 场景端订单id
     * @param channel 渠道号
     * @param customerId 客户号
     * @return int
     */
    int updateByCustomerIdAndSceneOrderId(String tenantId, String sceneOrderId, String channel,String customerId, String orderState);

    int batchInsertSelective(List<TlRightsExchangeLog> exchangeLogList);

    /**
     * 根基租户号、充值账号、被推荐人customerId、活动id 查询记录
     * @param tenantId
     * @param chargeAccount
     * @param recommended
     * @param activityId
     * @return
     */
    List<TlRightsExchangeLog> selectByChargeAccountAndRecommendedAndActivityId(String tenantId,String chargeAccount,
                                                                               String recommended,String activityId);

    /**
     * 根基客户号、租户号、渠道 查询记录
     * @param customerId
     * @param tenantId
     * @param channel
     * @return
     */
    List<TlRightsExchangeLog> listByCustomerIdAndTenantIdAndChannel(String customerId, String tenantId, String channel);

    /**
     * 根据客户编号，查找最新的若干条记录
     * @param customerId
     * @param tenantId
     * @param channel
     * @return
     */
    List<TlRightsExchangeLog> selectLatestLogsByCustomer(String customerId, String tenantId, String channel, int latestRows);

    /**
     * 根据id和客户信息，查询记录
     * @param id
     * @param customerId
     * @param tenantId
     * @param channel
     * @return
     */
    TlRightsExchangeLog selectByIdAndCustomerId(Long id, String customerId, String tenantId, String channel);

    List<TlRightsExchangeLog> selectByChargeAccountAndRecommendedAndActivityIdAndTenantId(String tenantId,String chargeAccount,
                                                                               String recommended,String activityId);

    /**
     * 根据租户好、邀请人手机号、被推荐人customerId 查询记录
     *
     * @param tenantId
     * @param customerPhone
     * @param recommended
     * @return
     */
    List<TlRightsExchangeLog> selectByCustomerPhoneAndRecommended(String tenantId, String customerPhone, String recommended);

    TlRightsExchangeLog findBySceneOrderIdAndPlatOrderId(String tenantId, String customerId, String sceneOrderId, String platOrderId);
}
